package com.epi.one.main;

import com.epi.one.basic.generic.task.Task;

/**
 * @author dxy
 * @version 1.0
 */
public class ConCurrentDemo {
    private static final ThreadLocal<String> threadLocal = ThreadLocal.withInitial(()->{
        System.out.println("ThreadLocal init~ ");
        return Thread.currentThread().getName();
    });


    public static void main(String[] args) {
        test();
    }

    public static void test() {
        threadLocal();
    }

    private static void threadLocal() {
        Runnable task = Task.asRunnable(()->{
            threadLocal.set(threadLocal.get() + " add ");
            System.out.println("["+ Thread.currentThread().getName() + "]" + threadLocal.get());
        });

        new Thread(task, "AAA").start();
        new Thread(task, "BBB").start();
    }
}
